﻿Public Class frm_main
    Public directory As String = Nothing

    Private Sub btn_sel_fold_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_sel_fold.Click

        Dim ops As New operations

        If fold_browse.ShowDialog = Windows.Forms.DialogResult.OK And fold_browse.SelectedPath <> Nothing Then
            directory = fold_browse.SelectedPath
            If System.IO.Directory.Exists(directory) Then
                txt_selected.Text = directory
                btn_apply.Enabled = True
            End If
        End If
        lbl_loading.Text = "Scanning...Please wait..."
        txt_files.Text = ops.get_files(directory).ToString
        txt_folders.Text = ops.get_folders(directory).ToString
        lbl_loading.Text = Nothing
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Close()
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        MessageBox.Show("Metroid_Lover's very own attribute editor" & vbCrLf & vbCrLf & _
                        "                    By: Pasky", "About Metroid Attributes", _
                        MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub btn_apply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_apply.Click
        Dim ops As New operations
        Dim type As Integer = 0

        If rad_files.Checked = True Then
            type = 0
        ElseIf rad_folders.Checked = True Then
            type = 1
        ElseIf rad_both.Checked = True Then
            type = 2
        End If

        ops.apply_atrributes(directory, chk_ro.Checked, chk_hidden.Checked, _
                             chk_system.Checked, chk_archive.Checked, type, chk_sub_fold.Checked)
        txt_files.Text = ops.get_files(directory).ToString
        txt_folders.Text = ops.get_folders(directory).ToString
    End Sub
End Class
